package com.ma.multi_thread;

/**
 * @ClassName TestSynchronized
 * @Author: mayongqiang
 * @DATE 2022/3/28 9:59
 * @Description:
 */
public class TestSynchronized {
    public static void main(String[] args) {
        TestSynchronized t = new TestSynchronized();
        new Thread(()->{
            t.test1();

        },"t1").start();
        new Thread(()->{
            t.test2();
        },"t2").start();

    }

    public synchronized  void test1(){
        System.out.println(System.currentTimeMillis()+"test1");
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    public synchronized static void test2(){
        System.out.println(System.currentTimeMillis()+"test2");
    }
}
